#include "DerivationTree.h"
#include "Expression.h"
#include <cmath>

ColonNode::ColonNode() : NodeTree_CRTP<ColonNode>() { }

ColonNode::ColonNode(const AutoPointer<NodeTree>& _left, const AutoPointer<NodeTree>& _right) : NodeTree_CRTP<ColonNode>(), left(_left), right(_right) { }

ColonNode::ColonNode(const ColonNode& copy) : NodeTree_CRTP<ColonNode>(copy), left(copy.left), right(copy.right) { }

bool ColonNode::execute(Pointer<LeonardVirtualMachine> LVM) {
	left->execute(LVM);
	right->execute(LVM);
	AutoPointer<TreeExpression::Expression> second = LVM->top();
	LVM->pop();
	AutoPointer<TreeExpression::Expression> first = LVM->top() ;
	LVM->pop();
	first->addLeaf(second);
	LVM->push(first);
	return true;
}
